﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class TransAm:BuffAction
    {
        private int speedMulti;
        private float dmgMulti, defMutli, avoidMulti;

        public TransAm(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel, string name, int duration, bool isBuff, 
            int speedMulti, float dmgMulti, float defMulti, float avoidMulti)
            : base(c, persistant, row, colEnd, count, lockoutLevel, name, duration, isBuff)
        {
            this.speedMulti = speedMulti;
            this.dmgMulti = dmgMulti;
            this.defMutli = defMulti;
            this.avoidMulti = avoidMulti;
        }

        public override void DoAction(GameController gc)
        {
            if (Core.TimerTicks(timer) == 0 && !IsActive)
            {
                c.Buffs.Add(this);
                Core.StartTimer(timer);
                IsActive = true;
                GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, row + c.offSetSpriteRow(), colEnd, count);
                c.StatModifier.SpeedMultiplier += speedMulti;
                c.StatModifier.DamageMultiplier += dmgMulti;
                c.StatModifier.DefenseMultiplier -= defMutli;
                c.StatModifier.AvoidanceMultiplier -= avoidMulti;
                if (c.State == GlobalConst.SpriteState.normalEast)
                     c.State = GlobalConst.SpriteState.transAmEast;
                else
                     c.State = GlobalConst.SpriteState.transAmWest;
            }

            if (IsActive && (c is Player) && (c as Player).Power > 0)
                (c as Player).Power -= 10;

            Reset(gc);
        }

        public override void Reset(GameController gc)
        {
            if ((Core.TimerTicks(timer) > duration || (c is Player) && (c as Player).Power <= 0) && IsActive)
            {
                IsActive = false;
                Core.StopTimer(timer);
                if (!c.GlobalLockout)
                    GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, c.offSetSpriteRow(), GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC);
                if (c.State == GlobalConst.SpriteState.transAmEast)
                    c.State = GlobalConst.SpriteState.normalEast;
                else
                    c.State = GlobalConst.SpriteState.normalWest;
                c.StatModifier.SpeedMultiplier -= speedMulti;
                c.StatModifier.DamageMultiplier -= dmgMulti;
                c.StatModifier.DefenseMultiplier += defMutli;
                c.StatModifier.AvoidanceMultiplier += avoidMulti;
            }
        }
    }
}
